import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/course/csEnrollments/queryEnrollmentView',
  save='/course/csEnrollments/add',
  edit='/course/csEnrollments/edit',
  deleteOne = '/course/csEnrollments/delete',
  importExcel = '/course/csEnrollments/importExcel',
  downloadTemplate = '/course/csEnrollments/downloadTemplate',
}
/**
 * 导出api
 * @param params
 */
export const getownloadTemplate = Api.downloadTemplate;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.post({url: Api.deleteOne, params}).then(() => {
    handleSuccess();
  });
}

/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  return defHttp.post({url: url, params});
}
